<?php

/*
  http://www.cristalab.com/tutoriales/formato-tipo-titulo-a-textos-con-php-respetando-acentos-c103378l/
 */
global $footer, $data;

class Contributors extends CI_Controller {

    public function __construct() {
        parent::__construct();
        global $footer, $data;
        if ($this->session->userdata('lang') == 'spanish') {
            $this->lang->load('about', 'spanish');
            $footer = "footer";
            $data['icon_lang'] = "en.jpg";
        } else {
            $this->lang->load('about', 'english');
            $footer = "footer_en";
            $data['icon_lang'] = "es.jpg";
        }
        $this->cargarIdioma();
        $data['place'] = "contributors";
        $this->registrar_visita($data['place']);
    }

    public function index() {
        global $footer, $data;

        $data['colaborador'] = $this->ciempies_model->obtenerColaboradores();

        $this->load->view('template/front_end/header', $data);
        $this->load->view('front_end/contributors_main');
        $this->load->view('front_end/contributors_news');
        $this->load->view('template/front_end/' . $footer);
    }

    function cargarIdioma() {
        global $data;
        /*  traduccion del menú */
        $data['headerTituloNotros'] = $this->lang->line('headerTituloNotros');
        $data['headerTituloDescarg'] = $this->lang->line('headerTituloDescarg');
        $data['headerTituloHerram'] = $this->lang->line('headerTituloHerram');
        $data['headerTituloDocu'] = $this->lang->line('headerTituloDocu');
        $data['headerTituloCol'] = $this->lang->line('headerTituloCol');
        $data['headerTituloNoticias'] = $this->lang->line('headerTituloNoticias');
        $data['headerTituloContcato'] = $this->lang->line('headerTituloContcato');

        $data['contribMainTitle'] = $this->lang->line('contribMainTitle');
        $data['contribNewsTitle'] = $this->lang->line('contribNewsTitle');
        $data['contribNewsCont'] = $this->lang->line('contribNewsCont');
    }

    public function lenChg() {
        global $data;
        if ($this->session->userdata('lang') == 'spanish') {
            $this->session->set_userdata('lang', 'english');
        } else {
            $this->session->set_userdata('lang', 'spanish');
        }
        redirect(base_url() . $data['place']);
    }

    public function registrar_visita($place) {
        $v_sitio = "ciempiess.org/$place";
        $v_date = date('Y-m-j H:i:s');
        $v_ip = $this->input->ip_address();
        $this->ciempies_model->registrar_visita($v_sitio, $v_date, $v_ip);
    }

}
